package coffee;
import java.util.Scanner;
import java.util.Objects;
public class Product {
     String code;
     String description;
     double price;
     Scanner sc=new Scanner(System.in);
     public Product(String initialCode,String initialDescription,double initialPrice)
     {
    	 this.code=initialCode;
    	 this.description=initialDescription;
    	 this.price=initialPrice;
     }
     public String getCode()
     {
    	 return code;
     }
     public String Description()
     {
    	 return description;
     }
     public Double getPrice()
     {
    	 return price;
     }
     public String toString()
     {  
    	 return code + "_" + description + "_" + price;
    	 
     }
     public boolean equals(Object obj) {
 		if (obj == this) {return true;}
 		if (obj == null) {return false;}
 		if (obj instanceof Product) {
 			Product product = (Product) obj;
 			boolean flag = this.code.equals(product.code) && this.price ==product.price;
 			return flag;
 		}
 		return false;
 	}	
     public int hashCode() { //重写equals的同时也要重写hashCode，因为同一对象的hashCode永远相等
         return Objects.hash(code,description); //调用Objects类，这是Object类的子类
     }
}